package com.baoer.controller;

import com.baoer.R;
import com.baoer.entity.ProductComment;
import com.baoer.service.ProductCommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class ProductCommentController {
    @Autowired
    private ProductCommentService commentService;

    /**
     * 获取产品评论列表
     */
    @GetMapping("/product/{productId}")
    public R getCommentsByProductId(@PathVariable Integer productId) {
        List<ProductComment> commentsByProductId = commentService.getCommentsByProductId(productId);
        return R.ok(commentsByProductId) ;
    }
}    